package main;

import java.io.IOException;
import java.net.ServerSocket;
import side_server.Server_Launch;

public class Launch {
	private ServerSocket svrSocket;
	
	public Launch(int port,String localfolder)
	{
		super();
		if (initServer(port))
		{
			Server_Launch server = Server_Launch.getInstance();
			server.setPort(port);
			server.setLocalFolder(localfolder);
			server.setServerSocket(svrSocket);
			new Thread(server).start();
		}
		else
		System.out.println("IMPOSSIBILE CREARE IL SERVER!!!");
	}
	
	private boolean initServer(int port)
	{
		try {
			svrSocket=new ServerSocket(port);
			return true;
		} catch (IOException e) {
			System.out.println("ERRORE DURANTE LA CREAZIONE DEL SERVER SULLA PORTA " + port);
			return false;
		}
	}
}
